
// https://leetcode.cn/problems/two-sum/submissions/555479601/
struct Solution {}

impl Solution {
    pub fn two_sum(nums: Vec<i32>, target: i32)-> Vec<i32> {
        let mut i_count: i32 = 0;
        let mut res: Vec<i32> = vec![];
        for i in &nums {
            // println!("i_count = {}", i_count);
            let mut j_count: i32 = 0;
            for j in &nums{
                if j_count > i_count {
                    // println!("j_count = {}", j_count);
                    if i + j == target {
                        res.push(i_count);
                        res.push(j_count);
                        // println!("{} {} {} {}", i, j, i_count, j_count);
                        // break;
                    };
                }
                j_count += 1;
            }
            // println!("res.len() = {}", res.len());
            if res.len() > 0 {
                // println!("res.len() = {} break", res.len());
                break;
            }
            i_count += 1;
        }
        res
    }
}

pub fn main() {
    println!("Hello, world!");
    let nums: Vec<i32> = vec![3,2,4];
    let target: i32 = 6;
    let v: Vec<i32> = Solution::two_sum(nums, target);
    for i in &v {
        println!("{}", i);
    }
}
